package org.ume.school.modules.model.entity;

import org.ume.school.modules.utils.TimeUtils;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * `comment_id` bigint(20) NOT NULL COMMENT '评论id',
 * `goods_id` varchar(64) DEFAULT NULL COMMENT '商品id',
 * `goods_name` varchar(64) DEFAULT NULL COMMENT '评论商品名称',
 * `comment_cont` varchar(256) DEFAULT NULL COMMENT '评论文本+评论图片url',
 * `comm_lev` tinyint(4) DEFAULT NULL COMMENT '评价等级:3:好评；2中评；1差评。',
 * `user_id` bigint(20) DEFAULT NULL COMMENT '评论用户',
 * `user_name` varchar(50) DEFAULT NULL COMMENT '用户名称',
 * `create_time` timestamp NULL DEFAULT NULL COMMENT '评论时间',
 * `status` tinyint(4) DEFAULT NULL COMMENT '删除标记0：可用；1、已删除；2、禁用',
 * Created by Django on 2017/8/5.
 */
@Entity
@Table(name = "vshop_goods_comment")
public class Comment implements Serializable {


    @Column(name = "comment_id", columnDefinition = "varchar(64) NOT NULL COMMENT '评论id'")
    @Id
    private String commentId;

    @Column(name = "goods_id", columnDefinition = "varchar(64) DEFAULT NULL COMMENT '商品id'")
    private String goodsId;

    @Column(name = "goods_name", columnDefinition = "varchar(64) DEFAULT NULL COMMENT '评论商品名称'")
    private String goodsName;

    @Column(name = "comment_cont", columnDefinition = "varchar(256) DEFAULT NULL COMMENT '评论文本+评论图片url'")
    private String content;

    @Column(name = "comm_lev", columnDefinition = "tinyint(4) DEFAULT NULL COMMENT '评价等级:3:好评；2中评；1差评。'")
    private Integer commLevel = 3;

    @Column(name = "user_id", columnDefinition = "varchar(64) DEFAULT NULL COMMENT '评论用户'")
    private String userId;

    @Column(name = "user_name", columnDefinition = "varchar(64) DEFAULT NULL COMMENT '用户名称'")
    private String userName;

    @Column(name = "user_head_image", columnDefinition = "varchar(128) DEFAULT NULL COMMENT '用户头像'")
    private String userHeadImage;

    @Column(name = "create_time", columnDefinition = "timestamp NULL DEFAULT NULL COMMENT '评论时间'")
    private Date createTime;

    @Column(name = "status", columnDefinition = "tinyint(4) DEFAULT NULL COMMENT '删除标记0：可用；1、已删除；2、禁用'")
    private Integer status = 0;


    public String getCommentId() {
        return commentId;
    }

    public void setCommentId(String commentId) {
        this.commentId = commentId;
    }

    public String getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(String goodsId) {
        this.goodsId = goodsId;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Integer getCommLevel() {
        return commLevel;
    }

    public void setCommLevel(Integer commLevel) {
        this.commLevel = commLevel;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getUserHeadImage() {
        return userHeadImage;
    }

    public void setUserHeadImage(String userHeadImage) {
        this.userHeadImage = userHeadImage;
    }

    @Transient
    private String sdate;

    public String getSdate() {
        if (null != this.getCreateTime()) {
            sdate = TimeUtils.parseNLPattern(this.getCreateTime());
        }
        return sdate;
    }

    public void setSdate(String sdate) {
        this.sdate = sdate;
    }
}
